package com.EpidemicPrevention.controller;


import com.EpidemicPrevention.pojo.Login;
import com.EpidemicPrevention.service.LoginServiceImpl;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/LoginController")
public class LoginController {
    @Autowired
    private LoginServiceImpl loginService;
    @PostMapping("/login")
    @ResponseBody
    @CrossOrigin
    public JSON login(String username, String password, HttpSession session){
        Login login = new Login();
        login.setUsername(username);
        login.setPassword(password);
        return loginService.Login(login,session);
    }
    @PostMapping("/session")
    @ResponseBody
    @CrossOrigin
    public Object session(HttpSession session,String key){
        return session.getAttribute(key);
    }

}
